#ifndef unigame_Input_h
#define unigame_Input_h

#include <vector>
#include "transform/Vector2.h"
#include "config/Def.h"

namespace unigame
{
	enum InputAction
	{
		E_PRESSING_IA = 1,
		E_PRESS_IA = 1 << 1,
		E_RELEASE_IA = 1 << 2,
		E_DRAG_IA = 1 << 3,
		E_MOVE_IA = 1 << 4,
	};

	enum MouseButton
	{
		E_NONE_MB = 0,
		E_LEFT_MB,
		E_RIGHT_MB,
		E_MIDDLE_MB,
		E_COUNT_MB,
	};

	enum KeyButton
	{
		E_0_KB = 0,
		E_1_KB,
		E_2_KB,
		E_3_KB,
		E_4_KB,
		E_5_KB,
		E_6_KB,
		E_7_KB,
		E_8_KB,
		E_9_KB,
		E_SUB_KB,
		E_ADD_KB,
		E_DOT_KB,
		E_COLON_KB,
		E_QUOT_KB,
		E_COMMA_KB,
		E_PERIOD_KB,
		E_SLASH_KB,
		E_L_SB_KB,
		E_R_SB_KB,
		E_QUES_KB,
		E_F1_KB,
		E_F2_KB,
		E_F3_KB,
		E_F4_KB,
		E_F5_KB,
		E_F6_KB,
		E_F7_KB,
		E_F8_KB,
		E_F9_KB,
		E_F10_KB,
		E_F11_KB,
		E_F12_KB,
		E_BACK_SPACE_KB,
		E_TAB_KB,
		E_CAP_KB,
		E_APP_KB,
		E_L_SHIFT_KB,
		E_L_CTRL_KB,
		E_L_ALT_KB,
		E_R_SHIFT_KB,
		E_R_CTRL_KB,
		E_R_ALT_KB,
		E_SPACE_KB,
		E_ESC_KB,
		E_L_WIN_KB,
		E_R_WIN_KB,
		E_ENTER_KB,
		E_UP_KB,
		E_LEFT_KB,
		E_RIGHT_KB,
		E_DOWN_KB,
		E_DEL_KB,
		E_HOME_KB,
		E_END_KB,
		E_PAGE_UP_KB,
		E_PAGE_DOWN_KB,
		E_INS_KB,
		E_A_KB,
		E_B_KB,
		E_C_KB,
		E_D_KB,
		E_E_KB,
		E_F_KB,
		E_G_KB,
		E_H_KB,
		E_I_KB,
		E_J_KB,
		E_K_KB,
		E_L_KB,
		E_M_KB,
		E_N_KB,
		E_O_KB,
		E_P_KB,
		E_Q_KB,
		E_R_KB,
		E_S_KB,
		E_T_KB,
		E_U_KB,
		E_V_KB,
		E_W_KB,
		E_X_KB,
		E_Y_KB,
		E_Z_KB,
		E_COUNT_KB,
	};

	typedef struct _MouseMove
	{
		Vector2f m_position;
		Vector2f m_start;
		char m_flag;

		_MouseMove():m_position(0, 0), m_start(0, 0), m_flag(0){}

		void reset()
		{
			m_flag &= E_PRESSING_IA;
		}

		void direction(Vector2f& direct)
		{
			direct.x = m_position.x - m_start.x;
			direct.y = m_position.y - m_start.y;
		}
	}MouseMove;

	class Input
	{
	public:
		~Input(){};

		static Input* instance();
		static void destroy();

		MouseMove* mouse()
		{
			return m_mouses;
		}

		void touchNumber(int32u num)
		{
			m_touchNumber = num;
		}

		int32u touchNumber()
		{
			return m_touchNumber;
		}

		char* keyButtonFlag()
		{
			return m_keyButtons;
		}

		void update();

	private:
		Input();

	private:
		static Input* s_instance;

		MouseMove m_touchs[10];
		int32u m_touchNumber;

		char m_keyButtons[E_COUNT_KB];

		MouseMove m_mouses[E_COUNT_MB];
	};
}

#endif